<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js"> <!--<![endif]-->
    <!-- BEGIN HEAD -->
    <head>
    <include file="Public:meta"/>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
<include file="Public:header"/>
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <include file="Public:sidebar"/>
    <!-- BEGIN PAGE -->
    <div class="page-content">
        <!-- BEGIN PAGE CONTAINER-->
        <div class="container-fluid">
            <!-- BEGIN PAGE HEADER-->
            <div class="row-fluid">
                <!-- begin BCN -->
                <div class="row-fluid">
                    <div class="span12"><ul class="breadcrumb"><li><i class="icon-home"></i><a onfocus="blurLink(this);" href="{:U('Index/index')}">首页</a>&nbsp;<span class="icon-angle-right"></span>&nbsp;</li><li><a onfocus="blurLink(this);" href="{:U(CONTROLLER_NAME.'/index')}">{$ParentPageName|default="未命名"}</a>&nbsp;<span class="icon-angle-right"></span>&nbsp;</li><li>{$PageName|default="未命名"}</li></ul></div>
                </div>
                <!-- end BCN -->
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN PAGE CONTENT-->
            <div class="row-fluid">
                <div class="span12">
                    <!-- begin 高级搜索 -->
                    <form id="filter_form" class="form-horizontal form-common adv-search-box" method="get" action="">
                        <input name="m" type="hidden" value="{:(MODULE_NAME)}">
                        <input name="c" type="hidden" value="{:(CONTROLLER_NAME)}">
                        <input name="a" type="hidden" value="index">
                        <input name="filter" type="hidden" value="1">
                        <div class="portlet box light-grey">
                            <div class="portlet-title">
                                <div class="caption"><i class="icon-search"></i>高级搜索</div>
                                <div class="tools"><a href="javascript:;" class="expand"></a></div>
                            </div>
                            <div style="display:none;" class="portlet-body">
                                <notempty name="status_all">
                                    <div class="row-fluid">
                                        <div class="span12">
                                            <div class="control-group control-common">
                                                <label class="control-label"><span>状态</span></label>
                                                <div class="controls">
                                                    <volist name="status_all" id="vo">
                                                        <label class="checkbox">
                                                            <input type="checkbox" class="checkbox_item" value="{$vo.value}" <if condition="in_array($vo['value'], $_GET[$vo['status']])"> checked="checked" </if> name="{$vo.status}[]"/>
                                                            <span class="label label-{$vo.class}">{$vo.title}</span>&nbsp;
                                                        </label>
                                                    </volist>                                                
                                                    <label class="checkbox">
                                                        <input type="checkbox" class="checkbox_all" checked="checked" value="all" name=""/>
                                                        <span class="label ">所有</span>&nbsp;
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </notempty>
                                <notempty name="search">
                                    <volist name="search" id="vo">
                                        <div class="row-fluid">
                                            <div class="span6">
                                                <div class="control-group control-common">
                                                    <label class="control-label"><span>{$vo.label}</span></label>
                                                    <div class="controls">
                                                        <switch name="vo.type">
                                                            <case value="input">
                                                                <if condition="$vo['category'] eq normal">
                                                                    <input type="text" class="m-wrap" value="{$vo.value}" name="{$vo.name}">
                                                                <else/>
                                                                    <div class="input-append form_date" data-date="2012-12-21T15:25:00Z">
                                                                        <input type="text" class="m-wrap" name="{$vo.name}" value="{$vo.value}" placeholder="{$vo.label}" />
                                                                        <span class="add-on"><i class="icon-remove"></i></span>
                                                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                                                    </div>
                                                                </if>
                                                            </case>
                                                            <case value="select">
                                                                <select class="city m-wrap" name="{$vo.name}">
                                                                    <option value="">请选择{$vo.label}</option>
                                                                    {$vo.data}
                                                                </select>
                                                            </case>
                                                        </switch>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </volist>
                                </notempty>
                                <div class="search-actions">
                                    <button class="btn blue" id="filter" type="submit">筛选<i class="icon-filter"></i></button>
                                    <a href="{:U(CONTROLLER_NAME.'/index')}" class="btn">重置</a>
                                </div>
                            </div>
                        </div>
                    </form>
                    <!-- end 高级搜索 -->

                    <!-- begin 操作与分页 -->
                    <div class="row-fluid ">
                        <div class="dataTables_length pull-left">
                            <form id="limit_form" name="limit_form" method="post" action="">
                                <label for="limit_num">
                                    <select class="limit_num" id="limit_num" name="limit_num">
                                    <volist name="page_limit_num" id="vo">
                                        <option <eq name="_SESSION['page_limit_num']" value="$vo"> selected="selected" </eq> value="{$vo}">{$vo}</option>
                                    </volist>
                                    </select>
                                    个记录/每个页面
                                </label>
                            </form>
                        </div>
                        <div class="btn-item pull-left">
                            <!-- begin 操作 -->
                            <notempty name="action">
                                <volist name="action" id="vo">
                                    <if condition="checkAccess(CONTROLLER_NAME, $vo['access'])">
                                        <eq name="vo.access" value="save">
                                            <a class="btn blue" href="{:U(CONTROLLER_NAME.'/'.$vo['access'])}">{$vo.label}<i class="{$vo.class}"></i></a>
                                        <else/>
                                            <a class="btn blue" href="javascript:void(0)" id="{$vo['access']}">{$vo.label}<i class="{$vo.class}"></i></a>
                                        </eq>
                                    </if>
                                </volist>
                            </notempty>
                            <!-- end 操作 -->
                        </div>
                        <form id="data_import" class="hide" method="post" action="{:U(CONTROLLER_NAME.'/import')}" enctype="multipart/form-data">
                            <input type="file" name="import" class="data-import">
                        </form>
                        <div class="dataTables_filter pull-right">
                            <form id="search_form" class="search-form" name="search_form" method="get" action="">
                                <input name="m" type="hidden" value="{:(MODULE_NAME)}">
                                <input name="c" type="hidden" value="{:(CONTROLLER_NAME)}">
                                <input name="a" type="hidden" value="index">
                                <input class="m-wrap search-input" type="text" placeholder="搜索..." name="keyword" value="{$Think.get.keyword}"/>
                                <button class="btn green" id="search" type="submit">搜索</button><if condition="$Think.get.keyword neq ''"><a href="{:U(CONTROLLER_NAME.'/index')}" class="btn">返回<i class="icon-share-alt"></i></a></if>
                            </form>
                        </div>
                    </div>
                    <!-- end 操作与分页 -->
                    <div class="portlet-body">
                        <table class="table table-striped table-hover table-bordered">
                            <thead>
                                <tr>
                                    <th><input type="checkbox" class="check_all" /></th>
                                    <volist name="index_content" id="vo">
                                        <th class='hidden-phone sorting <if condition="$_GET['sorting'] eq $vo['field']" >sorting-{$_GET["order"]}</if>' data-status="{$vo.status}" data-sorting="{$vo.field}">{$vo.label}</th>
                                    </volist>
                                    <th>管理操作</th>
                                </tr>
                            </thead>
                            <notempty name="list">
                                <tbody>
                                    <volist name="list" id="vo">
                                        <tr>
                                            <td><input type="checkbox" class="check_list" value="{$vo.id}" /></td>
                                            <volist name="vo" id="item">
                                                <td class="hidden-phone" data-field="{$key}" data-id="{$vo.id}">{$item}</td>
                                            </volist>
                                            <td>
                                                <div class="action_btn">
                                                    <notempty name="edit_action">
                                                        <volist name="edit_action" id="v">
                                                            <if condition="checkAccess(CONTROLLER_NAME, $v['access'])">
                                                                <if condition="$v.type eq link">
                                                                    <a class="{$v.class}" href="{:U(CONTROLLER_NAME.'/'.$v['access'],array('id' => $vo['id']))}">{$v.label}</a>
                                                                <else/>
                                                                    <a class="{$v.class}" href="javascript:void(0)" data-id="{$vo['id']}" data-url="{:U(CONTROLLER_NAME.'/'.$v['access'],array('id' => $vo['id']))}">{$v.label}</a>
                                                                </if>
                                                            </if>
                                                        </volist>
                                                    </notempty>
    											</div>
                                            </td>
                                        </tr>
                                    </volist>
                                </tbody>
                            </notempty>
                        </table>
                    </div>
                    <div class="pages clearfix">
                        <notempty name="handle">
                            <div class="control-group pull-left">
                                <select class="list_op_type m-wrap">
                                    <volist name="handle" id="vo">
                                        <option value="{$vo.access}">{$vo.label}</option>
                                    </volist>
                                </select>
                                <button class="btn blue list_op">确定</button>
                            </div>
                        </notempty>
                        <include file="Public:page" />
                    </div>				
                </div>
            </div>
            <!-- END PAGE CONTENT-->
        </div>
        <!-- END PAGE CONTAINER-->
    </div>
    <!-- END PAGE -->
</div>
<!-- END CONTAINER -->
<include file="Public:footer"/>
<script type="text/javascript">
    jQuery(document).ready(function () {
        //修改数据字段编辑状态
        $('table>tbody>tr').each(function(){
            $(this).find('td').each(function(){
                var field = $(this).data('field');
                var obj = $(this);
                if(field != undefined){
                    var status = $('table>thead>tr>th[data-sorting='+field+']').data('status');
                    if(status){
                        obj.attr({'class':'hidden-phone editable instant-edit'});
                    }
                }
            });
        });


        //数据导出
        $('#export').click(function(){

            var data = $('#filter_form').serialize();
            var prefix = "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME,array('filter' => 1))}";
            var list = prefix.split('?');
            data = data.replace(list[1],'');

            url = "{:U(CONTROLLER_NAME.'/export')}" + data;

            window.location.href = url;
        });

        //数据导入
        $('#import').click(function (){
            $('.data-import').trigger('click');
        });
        $('.data-import').change(function (){
            var _form = $('#data_import');
            _form.ajaxSubmit({
                type:_form.attr('method'),
                url: _form.attr('action'),
                dataType: 'json',
                success:function(json){
                    alert(json.info);
                    if(json.status==1)window.location=location;
                }
            });
            return false;
        });

        /*查看详情*/
        $('.achieve').click(function(){
            var id = $(this).attr('data-id');
            var url = $(this).attr('data-url');
            
            $('body').modalmanager('loading');
            
            $.get(url, {id: id}, function(data){
                $('#ajax-modal').html(data).modal();
            });
            return false;
        });
    });
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>